<template>
	<view>
		<view class="container" v-if="list.length>0">
			<view class="order-card" v-for="order in list" :key="order.id">
				<view class="order-info">
					<view class="order-number">订单号：{{ order.order }}</view>
					<view class="layout">
						<view class="course-name">{{ order.trade_name }}</view>
						<view class="paid-amount">￥{{ order.price }}</view>
					</view>
					<view class="ly">
						<view class="ly-l">
							<view class="ly-l-l">
								<image class="instructor-photo" :src="order.head" style="border-radius: 50%;"  @click="toMixinIndex(1,{userId: order.user_id})"></image>
								<view class="instructor-name">主讲：{{ order.nickname }}</view>
							</view>
							<view class="course-expiry">视频有效期倒计时：{{ order.countdown }}</view>
							<view class="course-time">{{ order.end_time }}</view>
						</view>
						<view class="ly-r">
							<view class="evaluate-button" v-if="order.evaluation_status == 1" @click="toDetail(order)">去评价</view>
							<view class="evaluated-button ac" v-else @click="toDetail(order)">已评价</view>
						</view>
					</view>
				
				</view>
			</view>
		</view>
		<view class="noData" style="padding-bottom:120rpx;" v-else>
			<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
		</view>
	</view>
</template>

<script>
	import {
		InformationorderList
	} from '@/common/http/api.js'
	export default {
		data() {
			return {
				//分页
				params: {
					page: 1
				},
				isList: true,
				list: [],
			};
		},
		onShow() {
			this.init()
		},
		onReachBottom() {
			if(this.isList){
				this.params.page ++
				this.init()
			}
		},
		methods:{
			init(){
				uni.showLoading()
				InformationorderList(this.params).then(res=>{
					uni.hideLoading()
					if(Array.isArray(res.data) && res.data.length > 0) {
						if(this.params.page === 1) {
							this.list = res.data
						} else {
							this.list = this.list.concat(res.data)
						}
					} else {
						this.isList = false
					}
				})
			},
			toDetail(it){
				uni.navigateTo({
					url:'/pagesC/evaluate/evaluate?id=' + it.id
				})
			}
		}
	};
</script>

<style lang="scss">
	page {
		background: #F6F7F8;
	}
	.container {
		padding-top: 30rpx;
		
	}


	.order-card {
		margin: 0 auto;
		width: 690rpx;
		background-color: #fff;
		margin-bottom: 9rpx;
		border-radius: 20rpx;
	}

	.order-info {
		width: 100%;
		box-sizing: border-box;
		padding: 30rpx 16rpx;
		
	}

	.order-number {
		font-family: PingFang;
		font-weight: 400;
		font-size: 24rpx;
		color: #666666;
		margin-bottom: 24rpx;
	}
	.layout {
		display: flex;
		align-items: center;
		margin-bottom: 29rpx;
		.course-name {
			flex: 1;
			min-width: 0;
			font-family: PingFang;
			font-weight: bold;
			font-size: 30rpx;
			color: #131313;
		}
		.paid-amount {
			font-family: PingFang;
			font-weight: bold;
			font-size: 34rpx;
			color: #E11919;
			padding-left: 30rpx;
		}
	}
	.ly {
		display: flex;
		width: 100%;
		display: flex;
		.ly-l {
			min-width: 0;
			flex: 1;
			.ly-l-l {
				width: 100%;
				display: flex;
				align-items: center;
				margin-bottom: 37rpx;
				image {
					width: 70rpx;
					height: 70rpx;
					border-radius: 50%;
					margin-right: 14rpx;
				}
				.instructor-name {
					font-family: PingFang;
					font-weight: 400;
					font-size: 28rpx;
					color: #131313;
				}
			}
			.course-expiry {
				font-family: PingFang;
				font-weight: 400;
				font-size: 26rpx;
				color: #666666;
				margin-bottom: 19rpx;
			}
			.course-time {
				font-family: PingFang;
				font-weight: 400;
				font-size: 26rpx;
				color: #666666;
			}
		}
		.ly-r {
			margin-left: 20rpx;
			.evaluate-button {
				width: 155rpx;
				height: 66rpx;
				background: #12B475;
				border-radius: 33rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				font-family: PingFang;
				font-weight: 400;
				font-size: 26rpx;
				color: #FFFFFF;
			}
			.ac {
				width: 155rpx;
				height: 66rpx;
				background: #12B475;
				border-radius: 33rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				font-family: PingFang;
				font-weight: 400;
				font-size: 26rpx;
				color: #FFFFFF;
				background: #E5E5E5;
				color: #131313;
			}
		}
	}
</style>